package com.jgj.zxkj.lookandcheckjggroupinfo.record.nocheck;

import android.support.annotation.LayoutRes;
import android.support.v7.widget.GridLayoutManager;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jgj.zxkj.lookandcheckjggroupinfo.R;
import com.sa.all_cui.mix_ui.recycler.MultipleItemEntity;
import com.sa.all_cui.mix_ui.recycler.MultipleViewHolder;

/**
 * Created by all-cui on 2017/11/1.
 */

@SuppressWarnings("WeakerAccess")
public class SimpleRecyclerAdapter extends BaseQuickAdapter<MultipleItemEntity, MultipleViewHolder>
        implements BaseQuickAdapter.SpanSizeLookup {

    public SimpleRecyclerAdapter(@LayoutRes int layoutId) {
        super(layoutId);
        init();
    }

    private void init() {
        setSpanSizeLookup(this);
        openLoadAnimation();
        //多次执行动画
        isFirstOnly(false);
    }

    public static SimpleRecyclerAdapter create(int layoutId) {
        return new SimpleRecyclerAdapter(layoutId);
    }


    @Override
    protected void convert(MultipleViewHolder holder, MultipleItemEntity item) {
        final String router = item.getField(PageDataType.ROUTER);
        final String usage = item.getField(PageDataType.USAGE);
        final String department = item.getField(PageDataType.DEPARTMENT);
        final String applyTime = item.getField(PageDataType.HANDLE_TIME);
        holder.setText(R.id.tv_no_check_router, String.format(mContext.getString(R.string.pages_router_name), router));
        holder.setText(R.id.tv_no_check_usage, String.format(mContext.getString(R.string.pages_router_usage), usage));
        holder.setText(R.id.tv_no_check_department, String.format(mContext.getString(R.string.pages_department), department));
        holder.setText(R.id.tv_no_check_applytime, String.format(mContext.getString(R.string.pages_apply_time), applyTime));
    }

    @Override
    public int getSpanSize(GridLayoutManager gridLayoutManager, int position) {
        return 1;
    }


}
